package com.xscha.tableforge.constants;

import java.util.*;

/**
 * 选择字段选项常量
 */
public class SelectOptionConstants {

    // 默认颜色
    public static final String DEFAULT_COLOR = "#1890ff";

    // 默认选项名称
    public static final String DEFAULT_OPTION_NAME = "选项1";

    /**
     * 获取单选字段默认配置
     * @return 单选字段默认配置
     */
    public static Map<String, Object> getSingleSelectConfig() {
        Map<String, Object> config = new HashMap<>();
        config.put("choices", getDefaultChoices());
        return config;
    }

    /**
     * 获取多选字段默认配置
     * @return 多选字段默认配置
     */
    public static Map<String, Object> getMultiSelectConfig() {
        Map<String, Object> config = new HashMap<>();
        config.put("isMultiple", true);
        config.put("shouldNotify", false);
        config.put("choices", getDefaultChoices());
        return config;
    }

    /**
     * 获取默认选项列表
     * @return 默认选项列表
     */
    public static List<Map<String, String>> getDefaultChoices() {
        List<Map<String, String>> choices = new ArrayList<>();
        choices.add(createOption(DEFAULT_OPTION_NAME, DEFAULT_COLOR));
        return choices;
    }

    /**
     * 创建选项
     * @param name 选项名称
     * @param color 选项颜色
     * @return 选项Map
     */
    public static Map<String, String> createOption(String name, String color) {
        Map<String, String> option = new HashMap<>();
        option.put("id", UUID.randomUUID().toString());
        option.put("name", name);
        option.put("color", color);
        return option;
    }
}
